<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
</head>

<body>
    <div id="app">
        <com-a v-if="isif"></com-a>
        <com-b v-else></com-b>
        <button @click="btn">点击</button>
    </div>

    <template id="ComA">
      <h2>这是ComA组件</h2>
    </template>
    <template id="ComB">
      <h2>这是ComB组件</h2>
    </template>
    <script>
        let ComA = {
            template: "#ComA",
        };
        let ComB = {
            template: "#ComB",
        };
        new Vue({
            el: "#app",
            components: {
                ComA,
                ComB,
            },
            data: {
                message: "数据",
                isif: true,
            },
            methods: {
                btn() {
                    this.isif = !this.isif;
                },
            },
        });
    </script>
</body>

</html>